Automatically Opening a Device

When you issue a command and specify a device that is not open, MCI tries to open the device before implementing the command. The following rules apply to automatically opening devices:

    The automatic open feature works only with the command-string interface.

    The automatic open feature fails for commands that are specific to custom device drivers.

    Automatically opened devices do not respond to commands that use  all  as a device name.

    The automatic open feature does not let your application specify the  type  flag. Without the device name, MCI determines the device name from the entries in the registry. To use a specific device, you can combine the device name with the filename by using the exclamation point, as described in the reference material for the open1GMTS1P command.

 

If an application uses the automatic open feature to open a device, the application should check the return value of every subsequent open command to verify that the device is still open. MCI also automatically closes any device that it automatically opens. MCI typically closes a device in the following situations:

    The command is completed.

    You abort the command.

    You request notification in a subsequent command.

    MCI detects a failure.